Repository navigation
Conversation
…dev#825) A boundary component can export head = { title } as an object literal. Void reads it from the source and uses it as the page title, so titleTemplate applies to it like any other page.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the second half of #825
Summary
_not-foundand_errorcan now set their own page title withexport const head = { title: '...' }. The first half of the issue (applyingtitleTemplateto the default titles) already shipped in #827.Problem
The error pages could not say "Page not found" to match their heading.
renderPageFailure()(packages/void/src/pages/protocol.ts) only had the built-inNot Found/Internal Server Errortitles, and boundary components have no.servercompanion to export ahead()from.Solution
The component declares the title as an object literal. The scan reads it from source (like
layout, so no component is loaded), the boundary manifest carries it per render plan, andrenderPageFailure()resolves it throughresolveHead()as the page title.titleTemplatefrom config or middleware applies as for any page, and it wins over a middlewareheadDefaults.titlethe way a page title does. Boundaries that declare nothing keep today's titles.Only a static
{ title: '<string>' }is read. Anything else (variables, extra fields, functions,let) is ignored with a warning that shows the supported form, instead of silently dropping it. A status-dependent function would need the component module at render time, so I kept that out of this PR.Changes
packages/void/src/pages/scan.ts,types.tsheadfrom boundary components (tsx, Vue<script>, Svelte<script module>)packages/void/src/pages/boundary-plans.ts,router/compile.tspackages/void/src/pages/protocol.tsrenderPageFailure()packages/void/test/unit/page-boundaries.test.tsdocs/guide/pages-routing/errors.mdBefore / After
With
titleTemplate: '%s | My App':<title>Not Found | My App</title>becomes<title>Page not found | My App</title>.Testing done
Notes for reviewers